home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Software Contest 3
/
FM Towns Software Contest 3.iso
/
exp
/
astral
/
a1
/
game
/
source
/
autoplt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-07
|
8KB
|
307 lines
// "autoplt.c"
// オートデモ用管理プログラム
#include <stdio.h>
#include <spr.h>
#include "wire3d.h"
#include "sin8.c"
#include "scmds.h"
// #define PUT_POSITION
SCREEN_LOCATE Screen[MAX_OBJECT];
WIRE_SPACE Space[32];
ANGLE Angle[3]={0,0,0};
int Offset[3]={0,0,0};
extern WIRE_OBJECT Object[MAX_OBJECT];
int End_code=0;
int Count=0;
int N_page=0,W_page=1;
int Hit_point[32];
int Hit_size[32];
int Hit_score[32];
int Hit_my_fighter[32];
void pilot(int *movdata,void (*option)(void))
{
int i,j,w;
int obj_speed_rol[32][3],obj_speed_mov[32][3],obj_speed_movf[32];
int obj_locate[32][3];
int my_speed_movf=0,my_speed_mov3[3]={0,0,0},my_speed_rol[3]={0,0,0};
int obj_num=32;
int offset1[3]={0,0,0},offset2[3];
int *movdata_start;
for(i=0;i<32;i++){
obj_speed_rol[i][0]=0;
obj_speed_rol[i][1]=0;
obj_speed_rol[i][2]=0;
obj_speed_mov[i][0]=0;
obj_speed_mov[i][1]=0;
obj_speed_mov[i][2]=0;
obj_speed_movf[i]=0;
}
for(i=0;i<obj_num;i++){
Space[i].obj_no=-1;
}
movdata_start=movdata;
for(;;){
RESTART:
if(Count==*movdata){
for(;;){
switch(*(++movdata)){
case 0: // 自機移動スピード変更(直進)
my_speed_movf=*(++movdata);
break;
case 1: // 自機移動スピード変更(3方向)
my_speed_mov3[0]=*(++movdata);
my_speed_mov3[1]=*(++movdata);
my_speed_mov3[2]=*(++movdata);
break;
case 2: // 自機回転スピード変更
my_speed_rol[0]=*(++movdata);
my_speed_rol[1]=*(++movdata);
my_speed_rol[2]=*(++movdata);
break;
case 3: // 自機位置強制変更
offset1[0]=*(++movdata)<<7;
offset1[1]=*(++movdata)<<7;
offset1[2]=*(++movdata)<<7;
break;
case 4: // 自機角度強制変更
Angle[0]=*(++movdata);
Angle[1]=*(++movdata);
Angle[2]=*(++movdata);
break;
case 20: // 物体表示(絶対座標)
i=*(++movdata);
Space[i].obj_no=*(++movdata);
Hit_size[i]=Object[*movdata].size>>4;
Space[i].angle[0]=*(++movdata);
Space[i].angle[1]=*(++movdata);
Space[i].angle[2]=*(++movdata);
obj_locate[i][0]=*(++movdata)<<7;
obj_locate[i][1]=*(++movdata)<<7;
obj_locate[i][2]=*(++movdata)<<7;
Hit_point[i]=*(++movdata);
Hit_score[i]=*(++movdata);
Hit_my_fighter[i]=*(++movdata);
obj_speed_movf[i]=0;
obj_speed_mov[i][0]=0;
obj_speed_mov[i][1]=0;
obj_speed_mov[i][2]=0;
obj_speed_rol[i][0]=0;
obj_speed_rol[i][1]=0;
obj_speed_rol[i][2]=0;
break;
case 21: // 物体表示(オブジェクト相対座標)
i=*(++movdata);
Space[i].obj_no=*(++movdata);
Hit_size[i]=Object[*movdata].size>>4;
Space[i].angle[0]=*(++movdata);
Space[i].angle[1]=*(++movdata);
Space[i].angle[2]=*(++movdata);
j=*(++movdata);
if(Space[j].obj_no==-1){
Space[i].obj_no=-1;
}
obj_locate[i][0]=obj_locate[j][0];
obj_locate[i][1]=obj_locate[j][1];
obj_locate[i][2]=obj_locate[j][2];
Hit_point[i]=*(++movdata);
Hit_score[i]=*(++movdata);
Hit_my_fighter[i]=*(++movdata);
obj_speed_movf[i]=0;
obj_speed_mov[i][0]=0;
obj_speed_mov[i][1]=0;
obj_speed_mov[i][2]=0;
obj_speed_rol[i][0]=0;
obj_speed_rol[i][1]=0;
obj_speed_rol[i][2]=0;
break;
case 22: // 物体表示(オブジェクト相対座標・角度)
i=*(++movdata);
Space[i].obj_no=*(++movdata);
Hit_size[i]=Object[*movdata].size>>4;
Space[i].angle[0]=*(++movdata);
Space[i].angle[1]=*(++movdata);
Space[i].angle[2]=*(++movdata);
j=*(++movdata);
if(Space[j].obj_no==-1){
Space[i].obj_no=-1;
}
Space[i].angle[0]=Space[j].angle[0];
Space[i].angle[1]=Space[j].angle[2];
Space[i].angle[2]=Space[j].angle[2];
obj_locate[i][0]=obj_locate[j][0];
obj_locate[i][1]=obj_locate[j][1];
obj_locate[i][2]=obj_locate[j][2];
Hit_point[i]=*(++movdata);
Hit_score[i]=*(++movdata);
Hit_my_fighter[i]=*(++movdata);
obj_speed_movf[i]=0;
obj_speed_mov[i][0]=0;
obj_speed_mov[i][1]=0;
obj_speed_mov[i][2]=0;
obj_speed_rol[i][0]=0;
obj_speed_rol[i][1]=0;
obj_speed_rol[i][2]=0;
break;
case 23: // 物体表示(自機オフセット)
i=*(++movdata);
Space[i].obj_no=*(++movdata);
Hit_size[i]=Object[*movdata].size>>4;
Space[i].angle[0]=*(++movdata);
Space[i].angle[1]=*(++movdata);
Space[i].angle[2]=*(++movdata);
obj_locate[i][0]=offset1[0]+(*(++movdata)<<7);
obj_locate[i][1]=offset1[1]+(*(++movdata)<<7);
obj_locate[i][2]=offset1[2]+(*(++movdata)<<7);
Hit_point[i]=*(++movdata);
Hit_score[i]=*(++movdata);
Hit_my_fighter[i]=*(++movdata);
obj_speed_movf[i]=0;
obj_speed_mov[i][0]=0;
obj_speed_mov[i][1]=0;
obj_speed_mov[i][2]=0;
obj_speed_rol[i][0]=0;
obj_speed_rol[i][1]=0;
obj_speed_rol[i][2]=0;
break;
case 30: // 物体移動スピード変更(直進)
i=*(++movdata);
obj_speed_movf[i]=*(++movdata);
break;
case 31: // 物体移動スピード変更
i=*(++movdata);
obj_speed_mov[i][0]=*(++movdata)<<7;
obj_speed_mov[i][1]=*(++movdata)<<7;
obj_speed_mov[i][2]=*(++movdata)<<7;
break;
case 32: // 物体回転スピード変更
i=*(++movdata);
obj_speed_rol[i][0]=*(++movdata);
obj_speed_rol[i][1]=*(++movdata);
obj_speed_rol[i][2]=*(++movdata);
break;
case 40: // 物体No.変更(アニメーション)
i=*(++movdata);
if(Hit_point[i]!=0){
Space[i].obj_no=*(++movdata);
}
else{
++movdata;
}
break;
case 41: // 物体位置変更
i=*(++movdata);
obj_locate[i][0]=*(++movdata)<<7;
obj_locate[i][1]=*(++movdata)<<7;
obj_locate[i][2]=*(++movdata)<<7;
break;
case 42: // 物体角度変更
i=*(++movdata);
Space[i].angle[0]=*(++movdata);
Space[i].angle[1]=*(++movdata);
Space[i].angle[2]=*(++movdata);
break;
case 43: // 物体位置変更(自機オフセット)
i=*(++movdata);
obj_locate[i][0]=offset1[0]+(*(++movdata)<<7);
obj_locate[i][1]=offset1[1]+(*(++movdata)<<7);
obj_locate[i][2]=offset1[2]+(*(++movdata)<<7);
break;
case 90: // ループ
movdata=movdata_start;
Count=0;
goto RESTART;
case 99: // エンドマーク
goto EXIT_anarize;
default: // 処理終了
return;
}
}
EXIT_anarize:
movdata++;
}
Count++;
Angle[0]+=my_speed_rol[0];
Angle[1]+=my_speed_rol[1];
Angle[2]+=my_speed_rol[2];
offset2[1]=( my_speed_movf*sin_data[Angle[0]]);
offset2[2]=( my_speed_movf*cos_data[Angle[0]])>>7;
offset2[0]=(-offset2[2] * sin_data[Angle[1]]);
offset2[2]=( offset2[2] * cos_data[Angle[1]]);
offset1[0]+=offset2[0]+(my_speed_mov3[0]<<7);
offset1[1]+=offset2[1]+(my_speed_mov3[1]<<7);
offset1[2]+=offset2[2]+(my_speed_mov3[2]<<7);
Offset[0]=offset1[0]>>7;
Offset[1]=offset1[1]>>7;
Offset[2]=offset1[2]>>7;
for(i=0;i<32;i++){
if(Space[i].obj_no!=-1){
Space[i].angle[0]+=obj_speed_rol[i][0];
Space[i].angle[1]+=obj_speed_rol[i][1];
Space[i].angle[2]+=obj_speed_rol[i][2];
obj_locate[i][0]+=obj_speed_mov[i][0];
obj_locate[i][1]+=obj_speed_mov[i][1];
obj_locate[i][2]+=obj_speed_mov[i][2];
if(obj_speed_movf[i]!=0){
offset2[1]=( obj_speed_movf[i] *
sin_data[Space[i].angle[0]]);
offset2[2]=( obj_speed_movf[i] *
cos_data[Space[i].angle[0]])>>7;
offset2[0]=(-offset2[2] * sin_data[Space[i].angle[1]]);
offset2[2]=( offset2[2] * cos_data[Space[i].angle[1]]);
obj_locate[i][0]+=offset2[0];
obj_locate[i][1]+=offset2[1];
obj_locate[i][2]+=offset2[2];
}
Space[i].locate[0]=obj_locate[i][0]>>7;
Space[i].locate[1]=obj_locate[i][1]>>7;
Space[i].locate[2]=obj_locate[i][2]>>7;
}
}
#ifdef PUT_POSITION
printf("Count%5d:Angle=%3d,%3d,%3d Position=%6d,%6d,%6d\n",Count, \
Angle[0],Angle[1],Angle[2],Offset[0],Offset[1],Offset[2]);
#endif
if(End_code!=0)return;
w=N_page;N_page=W_page;W_page=w;
wait_VSYNC();
chgpage(N_page);
clear_screen(W_page,6);
star(Angle,W_page);
wirespace(Angle,Offset,obj_num,W_page);
option();
}
}